(()=> {
	let ele = {};
	
	ele.zone = $('#zone');
	ele.graybg = $('#graybg');
	
	ele.nav_bar = $('#nav-bar');
	ele.nav_bar.innerHTML = '' +
				'<img onclick="javascript:history.back()" src="http://img.qxgs.cc/tiantianlaishouzu/img/public/fanhui.png" >' +
				'<h1 id="nav-title">' + ('' || '标题未配置') + '</h1>' +
				'<a >' + '<img id="task" src="" alt="">' + '</a>';
				
	
	jobList();
	//地段列表
	function jobList() {
		let token = getCookie("token");
		ajax({
			url: API_PATH.JOB_LIST,
			method: 'GET',
			header: {
				'Authorization': token,
			},
			success: res => {
				if (res.code == 1) {
					jobDraw(res.data);
				}
				// else openTips(res.msg);
			}
		});
	}
	
	function jobDraw(_data) {
		let html = '';
		let ishas = '';  //0 未拥有  1 已拥有
		let isuse = '';  //0 未使用  1 已使用
		let btntxt = '';
		let btncls = '';
		let daynum = '';
		let txt = '';
		let cls = '';
		let time = '';
		let suo = '';
		let yinying = '';
		let firstimg = '<img src="http://img.qxgs.cc/tiantianlaishouzu/img/home/buff.png" alt="">';
		
		for (let i = 0; i < _data.length; i++) {
			ishas = _data[i].is_has == 1 ? '1' : '0';
			isuse = _data[i].is_use == 1 ? '1' : '0';
			day_num = _data[i].day_num == 1 ? '1' : '0';
			txt =  _data[i].is_has == 1 ? '已生效' : '未生效';
			cls =  _data[i].is_has == 1 ? 'buff3' : 'buffRed';
			time = _data[i].day_num == 0 ? '永久有效' : '有效' + _data[i].day_num + '天';
			
			// console.log(ishas == 1 && isuse == 1);
			if(ishas == 1 && isuse == 1) { //拥有且使用
				btntxt = '使用中';
				btncls = 'buff4';
			} else if(ishas == 1 && isuse == 0) { //拥有未使用
				btntxt = '使用';
				btncls = 'buff5';
			} else if(ishas == 0 && isuse == 0) { //未拥有未使用
				btntxt = '合成';
				btncls = 'buff6';
				suo = '<div class="suodi">'
							+'<img src="http://img.qxgs.cc/tiantianlaishouzu/img/home/suo.png" alt="">'
							+'<span>拥有地图：'+_data[i].debris+'/'+_data[i].active+'</span>'
						+'</div>';
				yinying = 'buffimg2';
				firstimg = '<img class="firstimg" src="http://img.qxgs.cc/tiantianlaishouzu/img/home/buff.png" alt="">';
			}
			// if()
			// console.log(suo);
			html = '<div class="tit">'
						+'--'
					+'</div>'
					+'<div class="shouyi">'
						+'--<br />--'
					+'</div>'
					+'<div class="center">'
						+'<div class="centerin">'
							+'<img src="http://img.qxgs.cc/tiantianlaishouzu/img/home/suo.png" alt="">'
							+'<span>待解锁</span>'
						+'</div>'
					+'</div>'
					+'<p class="shang">拥有商圈图：0/15</p>'
		}
		// console.log(html);
		ele.graybg.innerHTML = html;
		
		let buff6s = $('.buff6');
		for(let i = 0; i < buff6s.length; i++) {
			buff6s[i].onclick = (e) => {
				// console.log(e.target.getAttribute('data'));
				jobSynthesis(e.target.getAttribute('data'));
			}
		}
		
		let buff5s = $('.buff5');
		for(let i = 0; i < buff5s.length; i++) {
			buff5s[i].onclick = (e) => {
				// console.log(e.target.getAttribute('data'));
				jobUseit(e.target.getAttribute('data'));
			}
		}
		
		let sousuos = $('.sousuo');
		for(let i = 0; i < sousuos.length; i++) {
			sousuos[i].onclick = () => {
				location.href = '../page/preview.html';
			}
		}
	}
	
	
	
})()